<%@page import="co.gov.medellin.ssti.sub.model.dao.exception.DAOException"%>
<%@page import="co.gov.medellin.ssti.sub.paoyer.administration.model.vo.UserVO"%>
<%@page import="java.util.Collection"%>
<%@page import="co.gov.medellin.ssti.sub.service.ConsultasService"%>
<%@page contentType="text/html;charset=utf-8"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Usuarios Administradores</title>
<link href="<%= request.getContextPath() + "/css/bloques.css" %>"
	rel="stylesheet" type="text/css">
<script type="text/javascript">
function setValues(codigo, usuario) {
    opener.document.frmModificarPrograma.admincodigo.value = codigo;
    opener.document.frmModificarPrograma.usuario.value = usuario;
    window.close();                 
}
</script>
</head>
<%
    String doAction = request.getParameter("doAction"); 
    String usuario = request.getParameter("usuario");
    if (usuario == null) usuario = "";
%>
<body>
	<br />
	<p align="center" class="titulosenblanco">USUARIOS ADMINISTRADORES</p>
	<form name="frmCreateUser" method="post"
		action="usuariosadminprog2.jsp">
		<input type="hidden" name="doAction" value="execFind">
		<div align="center">
			<table
				style="width: 60%; border: 0; padding: 3px; border-spacing: 2px;">
				<tr>
					<td width="22%" class="celdatabla"><strong>Usuario</strong></td>
					<td width="78%"><input type="text" Class="form" name="usuario"
						value="<%=usuario%>" maxlength="40" size="40" /></td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="submit"
						value="Buscar" onclick="this.form.submit()" /></td>
				</tr>
			</table>
		</div>
		<%  if (doAction != null) { %>
		<%
        ConsultasService consulta = new ConsultasService(); 
        Collection<UserVO> rs = null;
        try {
    %>
		<%
            rs = consulta.getUsuAdmin(usuario);   
            if (rs != null && !rs.isEmpty()) {
        %>
		<div align="center">
			<table class="form"
				style="width: 60%; border: 0; padding: 2px; border-spacing: 3px;">
				<tr>
					<td width="10%" class="headerTable">CODIGO</td>
					<td width="65%" class="headerTable">NOMBRE</td>
					<td width="15%" class="headerTable">SELECCIONAR</td>
				</tr>
				<%  for(UserVO vo : rs) { %>
				<tr>
					<td class="form"><%=vo.getCode()%></td>
					<td class="form"><%=vo.getName()%></td>
					<td class="form"><input type="radio" name="seleccionar"
						onclick="setValues('<%=vo.getCode()%>', '<%=vo.getName()%>')" /></td>
				</tr>
				<%  }%>
			</table>
		</div>
		<%  } else { %>
		<div align="center" class="celdatabla">No se encontraron registros...</div>
		<%  } %>
		<%
        } catch(DAOException e) {
                e.printStackTrace();
        }
    %>
		<%  } %>
	</form>
</body>
</html>
